﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace Server
{
    public static class BaseClass
    {
        /// <summary>
        /// 服务器地址
        /// </summary>
        public static string ServerIp = "";

        /// <summary>
        /// 服务器端口
        /// </summary>
        public static int ServerPort = 0;

        /// <summary>
        /// 服务器是否连接
        /// </summary>
        public static bool ServerConnt = false;

        /// <summary>
        /// 服务器IP和端口是否设置
        /// </summary>
        public static bool IpPortIsNull = false;

        /// <summary>
        /// 服务器启动时间
        /// </summary>
        public static DateTime StartTime = DateTime.Now;






        /// <summary>
        /// 计算时间差 -小时
        /// </summary>
        /// <param name="dateBegin">开始时间</param>
        /// <param name="dateEnd">结束时间</param>
        /// <returns>返回(小时)单位</returns>
        public static string ExecDateDiff(DateTime dateBegin, DateTime dateEnd)
        {
            TimeSpan ts1 = new TimeSpan(dateBegin.Ticks);
            TimeSpan ts2 = new TimeSpan(dateEnd.Ticks);
            TimeSpan ts3 = ts1.Subtract(ts2).Duration();
            //你想转的格式
            return ts3.TotalHours.ToString();
        }
    }
}
